`include "../codigo/Comp.v"

module TComp();

    // Data
    reg [31:0] a;
    reg [31:0] b;

    // Sign
    reg [2:0] op;

    // Output
    wire compout;


    // --------------------------------------------------------------
    // Loads the comparison structure
    Comp Comparator(a, b, op, compout);


    // --------------------------------------------------------------
    // Calls up the tasks designed to test the comparator 
    initial
    begin

        // ----------------------------------------------------------
        $display("-----------------------------------------------------------------------\n>>> test_comparisons;\n    This function will do the comparisons of the values store inside A and B registers;\n");

        $display(">>> A = 10 | B = 20;\n");
        a = #0 10;
        b = #0 20;
        test_comparisons;

        $display(">>> A = 20 | B = 10;\n");
        a = #0 20;
        b = #0 10;
        test_comparisons;

        $display(">>> A = 15 | B = 15;\n");
        a = #0 15;
        b = #0 15;
        test_comparisons;

        $display(">>> A = -5 | B = -7;\n");
    	a = #0 -5;
	    b = #0 -7;
    	test_comparisons;

        $display(">>> A = -7 | B = -5;\n");
    	a = #0 -7;
	    b = #0 -5;
    	test_comparisons;

        $display(">>> A = -5 | B = -5;\n");
    	a = #0 -5;
	    b = #0 -5;
    	test_comparisons;

        $display(">>> A = -2 | B = 3;\n");
    	a = #0 -2;
	    b = #0 3;
    	test_comparisons;

        $display(">>> A = 3 | B = -2;\n");
    	a = #0 3;
	    b = #0 -2;
    	test_comparisons;

        $display(">>> A = -2 | B = -2;\n");
    	a = #0 -2;
	    b = #0 -2;
    	test_comparisons;

        $display(">>> A = 0 | B = 0;\n");
    	a = #0 0;
	    b = #0 0;
    	test_comparisons;

        $display(">>> A = -3 | B = 0;\n");
    	a = #0 -3;
	    b = #0 0;
    	test_comparisons;
        
        $display(">>> A = 0 | B = -3;\n");
    	a = #0 0;
	    b = #0 -3;
    	test_comparisons;

        $display(">>> A = 3 | B = 0;\n");
    	a = #0 3;
	    b = #0 0;
    	test_comparisons;
        
        $display(">>> A = 0 | B = 3;\n");
    	a = #0 0;
	    b = #0 3;
    	test_comparisons;

    end



    // --------------------------------------------------------------
    // Check all comparisons
    task test_comparisons;
    begin

        $display(">>> A = %d | B = %d;\n", a, b);

        op = 3'b000; #1;                
        $display(">>> A == B -> %d;", compout);

        op = 3'b001; #1;
        $display(">>> A >= B -> %d;", compout);

        op = 3'b010; #1;
        $display(">>> A <= B -> %d;", compout);

        op = 3'b011; #1;
        $display(">>> A >  B -> %d;", compout);

        op = 3'b100; #1;
        $display(">>> A <  B -> %d;", compout);

        op = 3'b101; #1;
        $display(">>> A != B -> %d;", compout);

        $display("\n");
        $display("------------------------------------------------");

    end
    endtask

endmodule
